import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/cinema/search',
    component: () => import('@/views/search')
  },
  {
    path: '/city',
    component: () => import('@/views/city')
  },
  {
    path: '/listDetails/:id',
    component: () => import('@/views/listDetails')
  },

  {
    path: '/cinema',
    component: () => import('@/views/Cinema')
  },
  {
    path: '/home',
    component: () => import('@/views/Home'),
    children: [
      {
        path: '/home/hit',
        component: () => import('@/views/homes/hit')
      },
      {
        path: '/home/upcoming',
        component: () => import('@/views/homes/upcoming')
      },
      // 只要执行/home 就指向为/home/hit
      {
        path: '/home',
        redirect: '/home/hit'
      }
    ]
  },
  {
    path: '*',
    redirect: '/home'
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
